<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Conc.Signal</span><span>
</span><span id="line-5"></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Conc.Signal.html#Signal"><span class="hs-identifier">Signal</span></a></span><span>
</span><span id="line-6"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Conc.Signal.html#HandlerFun"><span class="hs-identifier">HandlerFun</span></a></span><span>
</span><span id="line-7"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Conc.Signal.html#setHandler"><span class="hs-identifier">setHandler</span></a></span><span>
</span><span id="line-8"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Conc.Signal.html#runHandlers"><span class="hs-identifier">runHandlers</span></a></span><span>
</span><span id="line-9"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Conc.Signal.html#runHandlersPtr"><span class="hs-identifier">runHandlersPtr</span></a></span><span>
</span><span id="line-10"></span><span>        </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-11"></span><span>
</span><span id="line-12"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html"><span class="hs-identifier">Control.Concurrent.MVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier">MVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.MVar.html#newMVar"><span class="hs-identifier">newMVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Concurrent.MVar.html#withMVar"><span class="hs-identifier">withMVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-13"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Dynamic.html"><span class="hs-identifier">Data.Dynamic</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier">Dynamic</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-14"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.Types.html"><span class="hs-identifier">Foreign.C.Types</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier">CInt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-15"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.ForeignPtr.html"><span class="hs-identifier">Foreign.ForeignPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier">ForeignPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.ForeignPtr.Imp.html#newForeignPtr"><span class="hs-identifier">newForeignPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.StablePtr.html"><span class="hs-identifier">Foreign.StablePtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stable.html#castPtrToStablePtr"><span class="hs-identifier">castPtrToStablePtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stable.html#castStablePtrToPtr"><span class="hs-identifier">castStablePtrToPtr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>                          </span><span class="annot"><a href="GHC.Stable.html#deRefStablePtr"><span class="hs-identifier">deRefStablePtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stable.html#freeStablePtr"><span class="hs-identifier">freeStablePtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stable.html#newStablePtr"><span class="hs-identifier">newStablePtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Ptr.html"><span class="hs-identifier">Foreign.Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier">Ptr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#castPtr"><span class="hs-identifier">castPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Marshal.Alloc.html"><span class="hs-identifier">Foreign.Marshal.Alloc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Marshal.Alloc.html#finalizerFree"><span class="hs-identifier">finalizerFree</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Arr.html"><span class="hs-identifier">GHC.Arr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ix.html#inRange"><span class="hs-identifier">inRange</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Conc.Sync.html"><span class="hs-identifier">GHC.Conc.Sync</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Conc.Sync.html#forkIO"><span class="hs-identifier">forkIO</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.html"><span class="hs-identifier">GHC.IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.html#mask_"><span class="hs-identifier">mask_</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Unsafe.html#unsafePerformIO"><span class="hs-identifier">unsafePerformIO</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IOArray.html"><span class="hs-identifier">GHC.IOArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IOArray.html#IOArray"><span class="hs-identifier">IOArray</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IOArray.html#boundsIOArray"><span class="hs-identifier">boundsIOArray</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IOArray.html#newIOArray"><span class="hs-identifier">newIOArray</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>                    </span><span class="annot"><a href="GHC.IOArray.html#unsafeReadIOArray"><span class="hs-identifier">unsafeReadIOArray</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IOArray.html#unsafeWriteIOArray"><span class="hs-identifier">unsafeWriteIOArray</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Real.html"><span class="hs-identifier">GHC.Real</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier">fromIntegral</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Word.html"><span class="hs-identifier">GHC.Word</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-30"></span><span class="hs-comment">-- Signal handling</span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span class="hs-keyword">type</span><span> </span><span id="Signal"><span class="annot"><a href="GHC.Conc.Signal.html#Signal"><span class="hs-identifier hs-var">Signal</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span class="annot"><a href="GHC.Conc.Signal.html#maxSig"><span class="hs-identifier hs-type">maxSig</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-35"></span><span id="maxSig"><span class="annot"><span class="annottext">maxSig :: Int
</span><a href="GHC.Conc.Signal.html#maxSig"><span class="hs-identifier hs-var hs-var">maxSig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">64</span></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-keyword">type</span><span> </span><span id="HandlerFun"><span class="annot"><a href="GHC.Conc.Signal.html#HandlerFun"><span class="hs-identifier hs-var">HandlerFun</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span class="hs-comment">-- Lock used to protect concurrent access to signal_handlers.  Symptom</span><span>
</span><span id="line-40"></span><span class="hs-comment">-- of this race condition is GHC bug #1922, although that bug was on</span><span>
</span><span id="line-41"></span><span class="hs-comment">-- Windows a similar bug also exists on Unix.</span><span>
</span><span id="line-42"></span><span class="annot"><a href="GHC.Conc.Signal.html#signal_handlers"><span class="hs-identifier hs-type">signal_handlers</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IOArray.html#IOArray"><span class="hs-identifier hs-type">IOArray</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Conc.Signal.html#HandlerFun"><span class="hs-identifier hs-type">HandlerFun</span></a></span><span class="hs-special">,</span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span id="signal_handlers"><span class="annot"><span class="annottext">signal_handlers :: MVar (IOArray Int (Maybe (HandlerFun, Dynamic)))
</span><a href="GHC.Conc.Signal.html#signal_handlers"><span class="hs-identifier hs-var hs-var">signal_handlers</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (MVar (IOArray Int (Maybe (HandlerFun, Dynamic))))
-&gt; MVar (IOArray Int (Maybe (HandlerFun, Dynamic)))
forall a. IO a -&gt; a
</span><a href="GHC.IO.Unsafe.html#unsafePerformIO"><span class="hs-identifier hs-var">unsafePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (MVar (IOArray Int (Maybe (HandlerFun, Dynamic))))
 -&gt; MVar (IOArray Int (Maybe (HandlerFun, Dynamic))))
-&gt; IO (MVar (IOArray Int (Maybe (HandlerFun, Dynamic))))
-&gt; MVar (IOArray Int (Maybe (HandlerFun, Dynamic)))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-44"></span><span>  </span><span id="local-6989586621679562906"><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
</span><a href="#local-6989586621679562906"><span class="hs-identifier hs-var">arr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Int, Int)
-&gt; Maybe (HandlerFun, Dynamic)
-&gt; IO (IOArray Int (Maybe (HandlerFun, Dynamic)))
forall i e. Ix i =&gt; (i, i) -&gt; e -&gt; IO (IOArray i e)
</span><a href="GHC.IOArray.html#newIOArray"><span class="hs-identifier hs-var">newIOArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Conc.Signal.html#maxSig"><span class="hs-identifier hs-var">maxSig</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe (HandlerFun, Dynamic)
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-45"></span><span>  </span><span id="local-6989586621679562905"><span class="annot"><span class="annottext">MVar (IOArray Int (Maybe (HandlerFun, Dynamic)))
</span><a href="#local-6989586621679562905"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
-&gt; IO (MVar (IOArray Int (Maybe (HandlerFun, Dynamic))))
forall a. a -&gt; IO (MVar a)
</span><a href="GHC.MVar.html#newMVar"><span class="hs-identifier hs-var">newMVar</span></a></span><span> </span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
</span><a href="#local-6989586621679562906"><span class="hs-identifier hs-var">arr</span></a></span><span>
</span><span id="line-46"></span><span>  </span><span class="annot"><span class="annottext">MVar (IOArray Int (Maybe (HandlerFun, Dynamic)))
-&gt; (Ptr (MVar (IOArray Int (Maybe (HandlerFun, Dynamic))))
    -&gt; IO (Ptr (MVar (IOArray Int (Maybe (HandlerFun, Dynamic))))))
-&gt; IO (MVar (IOArray Int (Maybe (HandlerFun, Dynamic))))
forall a. a -&gt; (Ptr a -&gt; IO (Ptr a)) -&gt; IO a
</span><a href="GHC.Conc.Signal.html#sharedCAF"><span class="hs-identifier hs-var">sharedCAF</span></a></span><span> </span><span class="annot"><span class="annottext">MVar (IOArray Int (Maybe (HandlerFun, Dynamic)))
</span><a href="#local-6989586621679562905"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr (MVar (IOArray Int (Maybe (HandlerFun, Dynamic))))
-&gt; IO (Ptr (MVar (IOArray Int (Maybe (HandlerFun, Dynamic)))))
forall a. Ptr a -&gt; IO (Ptr a)
</span><a href="GHC.Conc.Signal.html#getOrSetGHCConcSignalSignalHandlerStore"><span class="hs-identifier hs-var">getOrSetGHCConcSignalSignalHandlerStore</span></a></span><span>
</span><span id="line-47"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.Conc.Signal.html#signal_handlers"><span class="hs-pragma hs-type">signal_handlers</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span id="local-6989586621679562981"><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;getOrSetGHCConcSignalSignalHandlerStore&quot;</span></span><span>
</span><span id="line-50"></span><span>  </span><span id="getOrSetGHCConcSignalSignalHandlerStore"><span class="annot"><a href="GHC.Conc.Signal.html#getOrSetGHCConcSignalSignalHandlerStore"><span class="hs-identifier hs-var">getOrSetGHCConcSignalSignalHandlerStore</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679562981"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679562981"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-51"></span><span>
</span><span id="line-52"></span><span class="annot"><a href="GHC.Conc.Signal.html#setHandler"><span class="hs-identifier hs-type">setHandler</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Conc.Signal.html#Signal"><span class="hs-identifier hs-type">Signal</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Conc.Signal.html#HandlerFun"><span class="hs-identifier hs-type">HandlerFun</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Conc.Signal.html#HandlerFun"><span class="hs-identifier hs-type">HandlerFun</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Dynamic.html#Dynamic"><span class="hs-identifier hs-type">Dynamic</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span id="setHandler"><span class="annot"><span class="annottext">setHandler :: Signal
-&gt; Maybe (HandlerFun, Dynamic) -&gt; IO (Maybe (HandlerFun, Dynamic))
</span><a href="GHC.Conc.Signal.html#setHandler"><span class="hs-identifier hs-var hs-var">setHandler</span></a></span></span><span> </span><span id="local-6989586621679562902"><span class="annot"><span class="annottext">Signal
</span><a href="#local-6989586621679562902"><span class="hs-identifier hs-var">sig</span></a></span></span><span> </span><span id="local-6989586621679562901"><span class="annot"><span class="annottext">Maybe (HandlerFun, Dynamic)
</span><a href="#local-6989586621679562901"><span class="hs-identifier hs-var">handler</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-55"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679562897"><span class="annot"><span class="annottext">int :: Int
</span><a href="#local-6989586621679562897"><span class="hs-identifier hs-var hs-var">int</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Signal -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Signal
</span><a href="#local-6989586621679562902"><span class="hs-identifier hs-var">sig</span></a></span><span>
</span><span id="line-56"></span><span>  </span><span class="annot"><span class="annottext">MVar (IOArray Int (Maybe (HandlerFun, Dynamic)))
-&gt; (IOArray Int (Maybe (HandlerFun, Dynamic))
    -&gt; IO (Maybe (HandlerFun, Dynamic)))
-&gt; IO (Maybe (HandlerFun, Dynamic))
forall a b. MVar a -&gt; (a -&gt; IO b) -&gt; IO b
</span><a href="Control.Concurrent.MVar.html#withMVar"><span class="hs-identifier hs-var">withMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar (IOArray Int (Maybe (HandlerFun, Dynamic)))
</span><a href="GHC.Conc.Signal.html#signal_handlers"><span class="hs-identifier hs-var">signal_handlers</span></a></span><span> </span><span class="annot"><span class="annottext">((IOArray Int (Maybe (HandlerFun, Dynamic))
  -&gt; IO (Maybe (HandlerFun, Dynamic)))
 -&gt; IO (Maybe (HandlerFun, Dynamic)))
-&gt; (IOArray Int (Maybe (HandlerFun, Dynamic))
    -&gt; IO (Maybe (HandlerFun, Dynamic)))
-&gt; IO (Maybe (HandlerFun, Dynamic))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679562896"><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
</span><a href="#local-6989586621679562896"><span class="hs-identifier hs-var">arr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-57"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#not"><span class="hs-identifier hs-var">not</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Int, Int) -&gt; Int -&gt; Bool
forall a. Ix a =&gt; (a, a) -&gt; a -&gt; Bool
</span><a href="GHC.Ix.html#inRange"><span class="hs-identifier hs-var">inRange</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic)) -&gt; (Int, Int)
forall i e. IOArray i e -&gt; (i, i)
</span><a href="GHC.IOArray.html#boundsIOArray"><span class="hs-identifier hs-var">boundsIOArray</span></a></span><span> </span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
</span><a href="#local-6989586621679562896"><span class="hs-identifier hs-var">arr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679562897"><span class="hs-identifier hs-var">int</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-58"></span><span>      </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; IO (Maybe (HandlerFun, Dynamic))
forall a. [Char] -&gt; a
</span><a href="GHC.Err.html#errorWithoutStackTrace"><span class="hs-identifier hs-var">errorWithoutStackTrace</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;GHC.Conc.setHandler: signal out of range&quot;</span></span><span>
</span><span id="line-59"></span><span>      </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679562893"><span class="annot"><span class="annottext">Maybe (HandlerFun, Dynamic)
</span><a href="#local-6989586621679562893"><span class="hs-identifier hs-var">old</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
-&gt; Int -&gt; IO (Maybe (HandlerFun, Dynamic))
forall i e. IOArray i e -&gt; Int -&gt; IO e
</span><a href="GHC.IOArray.html#unsafeReadIOArray"><span class="hs-identifier hs-var">unsafeReadIOArray</span></a></span><span> </span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
</span><a href="#local-6989586621679562896"><span class="hs-identifier hs-var">arr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679562897"><span class="hs-identifier hs-var">int</span></a></span><span>
</span><span id="line-60"></span><span>              </span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
-&gt; Int -&gt; Maybe (HandlerFun, Dynamic) -&gt; IO ()
forall i e. IOArray i e -&gt; Int -&gt; e -&gt; IO ()
</span><a href="GHC.IOArray.html#unsafeWriteIOArray"><span class="hs-identifier hs-var">unsafeWriteIOArray</span></a></span><span> </span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
</span><a href="#local-6989586621679562896"><span class="hs-identifier hs-var">arr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679562897"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HandlerFun, Dynamic)
</span><a href="#local-6989586621679562901"><span class="hs-identifier hs-var">handler</span></a></span><span>
</span><span id="line-61"></span><span>              </span><span class="annot"><span class="annottext">Maybe (HandlerFun, Dynamic) -&gt; IO (Maybe (HandlerFun, Dynamic))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HandlerFun, Dynamic)
</span><a href="#local-6989586621679562893"><span class="hs-identifier hs-var">old</span></a></span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span class="annot"><a href="GHC.Conc.Signal.html#runHandlers"><span class="hs-identifier hs-type">runHandlers</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Conc.Signal.html#Signal"><span class="hs-identifier hs-type">Signal</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-64"></span><span id="runHandlers"><span class="annot"><span class="annottext">runHandlers :: ForeignPtr Word8 -&gt; Signal -&gt; IO ()
</span><a href="GHC.Conc.Signal.html#runHandlers"><span class="hs-identifier hs-var hs-var">runHandlers</span></a></span></span><span> </span><span id="local-6989586621679562892"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679562892"><span class="hs-identifier hs-var">p_info</span></a></span></span><span> </span><span id="local-6989586621679562891"><span class="annot"><span class="annottext">Signal
</span><a href="#local-6989586621679562891"><span class="hs-identifier hs-var">sig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-65"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679562888"><span class="annot"><span class="annottext">int :: Int
</span><a href="#local-6989586621679562888"><span class="hs-identifier hs-var hs-var">int</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Signal -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Signal
</span><a href="#local-6989586621679562891"><span class="hs-identifier hs-var">sig</span></a></span><span>
</span><span id="line-66"></span><span>  </span><span class="annot"><span class="annottext">MVar (IOArray Int (Maybe (HandlerFun, Dynamic)))
-&gt; (IOArray Int (Maybe (HandlerFun, Dynamic)) -&gt; IO ()) -&gt; IO ()
forall a b. MVar a -&gt; (a -&gt; IO b) -&gt; IO b
</span><a href="Control.Concurrent.MVar.html#withMVar"><span class="hs-identifier hs-var">withMVar</span></a></span><span> </span><span class="annot"><span class="annottext">MVar (IOArray Int (Maybe (HandlerFun, Dynamic)))
</span><a href="GHC.Conc.Signal.html#signal_handlers"><span class="hs-identifier hs-var">signal_handlers</span></a></span><span> </span><span class="annot"><span class="annottext">((IOArray Int (Maybe (HandlerFun, Dynamic)) -&gt; IO ()) -&gt; IO ())
-&gt; (IOArray Int (Maybe (HandlerFun, Dynamic)) -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679562887"><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
</span><a href="#local-6989586621679562887"><span class="hs-identifier hs-var">arr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-67"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#not"><span class="hs-identifier hs-var">not</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Int, Int) -&gt; Int -&gt; Bool
forall a. Ix a =&gt; (a, a) -&gt; a -&gt; Bool
</span><a href="GHC.Ix.html#inRange"><span class="hs-identifier hs-var">inRange</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic)) -&gt; (Int, Int)
forall i e. IOArray i e -&gt; (i, i)
</span><a href="GHC.IOArray.html#boundsIOArray"><span class="hs-identifier hs-var">boundsIOArray</span></a></span><span> </span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
</span><a href="#local-6989586621679562887"><span class="hs-identifier hs-var">arr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679562888"><span class="hs-identifier hs-var">int</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-68"></span><span>      </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-69"></span><span>      </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679562886"><span class="annot"><span class="annottext">Maybe (HandlerFun, Dynamic)
</span><a href="#local-6989586621679562886"><span class="hs-identifier hs-var">handler</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
-&gt; Int -&gt; IO (Maybe (HandlerFun, Dynamic))
forall i e. IOArray i e -&gt; Int -&gt; IO e
</span><a href="GHC.IOArray.html#unsafeReadIOArray"><span class="hs-identifier hs-var">unsafeReadIOArray</span></a></span><span> </span><span class="annot"><span class="annottext">IOArray Int (Maybe (HandlerFun, Dynamic))
</span><a href="#local-6989586621679562887"><span class="hs-identifier hs-var">arr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679562888"><span class="hs-identifier hs-var">int</span></a></span><span>
</span><span id="line-70"></span><span>              </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe (HandlerFun, Dynamic)
</span><a href="#local-6989586621679562886"><span class="hs-identifier hs-var">handler</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-71"></span><span>                </span><span class="annot"><span class="annottext">Maybe (HandlerFun, Dynamic)
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-72"></span><span>                </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679562885"><span class="annot"><span class="annottext">HandlerFun
</span><a href="#local-6989586621679562885"><span class="hs-identifier hs-var">f</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Dynamic
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">ThreadId
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO ThreadId
</span><a href="GHC.Conc.Sync.html#forkIO"><span class="hs-identifier hs-var">forkIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HandlerFun
</span><a href="#local-6989586621679562885"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679562892"><span class="hs-identifier hs-var">p_info</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span>                                  </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-74"></span><span>
</span><span id="line-75"></span><span class="hs-comment">-- It is our responsibility to free the memory buffer, so we create a</span><span>
</span><span id="line-76"></span><span class="hs-comment">-- foreignPtr.</span><span>
</span><span id="line-77"></span><span class="annot"><a href="GHC.Conc.Signal.html#runHandlersPtr"><span class="hs-identifier hs-type">runHandlersPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Conc.Signal.html#Signal"><span class="hs-identifier hs-type">Signal</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-78"></span><span id="runHandlersPtr"><span class="annot"><span class="annottext">runHandlersPtr :: Ptr Word8 -&gt; Signal -&gt; IO ()
</span><a href="GHC.Conc.Signal.html#runHandlersPtr"><span class="hs-identifier hs-var hs-var">runHandlersPtr</span></a></span></span><span> </span><span id="local-6989586621679562884"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679562884"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679562883"><span class="annot"><span class="annottext">Signal
</span><a href="#local-6989586621679562883"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-79"></span><span>  </span><span id="local-6989586621679562882"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679562882"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FinalizerPtr Word8 -&gt; Ptr Word8 -&gt; IO (ForeignPtr Word8)
forall a. FinalizerPtr a -&gt; Ptr a -&gt; IO (ForeignPtr a)
</span><a href="Foreign.ForeignPtr.Imp.html#newForeignPtr"><span class="hs-identifier hs-var">newForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">FinalizerPtr Word8
forall a. FinalizerPtr a
</span><a href="Foreign.Marshal.Alloc.html#finalizerFree"><span class="hs-identifier hs-var">finalizerFree</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679562884"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-80"></span><span>  </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Signal -&gt; IO ()
</span><a href="GHC.Conc.Signal.html#runHandlers"><span class="hs-identifier hs-var">runHandlers</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679562882"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Signal
</span><a href="#local-6989586621679562883"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="hs-comment">-- Machinery needed to ensure that we only have one copy of certain</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- CAFs in this module even when the base package is present twice, as</span><span>
</span><span id="line-84"></span><span class="hs-comment">-- it is when base is dynamically loaded into GHCi.  The RTS keeps</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- track of the single true value of the CAF, so even when the CAFs in</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- the dynamically-loaded base package are reverted, nothing bad</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- happens.</span><span>
</span><span id="line-88"></span><span class="hs-comment">--</span><span>
</span><span id="line-89"></span><span id="local-6989586621679562982"><span class="annot"><a href="GHC.Conc.Signal.html#sharedCAF"><span class="hs-identifier hs-type">sharedCAF</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679562982"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679562982"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679562982"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679562982"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-90"></span><span id="sharedCAF"><span class="annot"><span class="annottext">sharedCAF :: forall a. a -&gt; (Ptr a -&gt; IO (Ptr a)) -&gt; IO a
</span><a href="GHC.Conc.Signal.html#sharedCAF"><span class="hs-identifier hs-var hs-var">sharedCAF</span></a></span></span><span> </span><span id="local-6989586621679562875"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562875"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621679562874"><span class="annot"><span class="annottext">Ptr a -&gt; IO (Ptr a)
</span><a href="#local-6989586621679562874"><span class="hs-identifier hs-var">get_or_set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-91"></span><span>  </span><span class="annot"><span class="annottext">IO a -&gt; IO a
forall a. IO a -&gt; IO a
</span><a href="GHC.IO.html#mask_"><span class="hs-identifier hs-var">mask_</span></a></span><span> </span><span class="annot"><span class="annottext">(IO a -&gt; IO a) -&gt; IO a -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-92"></span><span>    </span><span id="local-6989586621679562873"><span class="annot"><span class="annottext">StablePtr a
</span><a href="#local-6989586621679562873"><span class="hs-identifier hs-var">stable_ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">a -&gt; IO (StablePtr a)
forall a. a -&gt; IO (StablePtr a)
</span><a href="GHC.Stable.html#newStablePtr"><span class="hs-identifier hs-var">newStablePtr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562875"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-93"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679562872"><span class="annot"><span class="annottext">ref :: Ptr b
</span><a href="#local-6989586621679562872"><span class="hs-identifier hs-var hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr () -&gt; Ptr b
forall a b. Ptr a -&gt; Ptr b
</span><a href="GHC.Ptr.html#castPtr"><span class="hs-identifier hs-var">castPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StablePtr a -&gt; Ptr ()
forall a. StablePtr a -&gt; Ptr ()
</span><a href="GHC.Stable.html#castStablePtrToPtr"><span class="hs-identifier hs-var">castStablePtrToPtr</span></a></span><span> </span><span class="annot"><span class="annottext">StablePtr a
</span><a href="#local-6989586621679562873"><span class="hs-identifier hs-var">stable_ref</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-94"></span><span>    </span><span id="local-6989586621679562871"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679562871"><span class="hs-identifier hs-var">ref2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; IO (Ptr a)
</span><a href="#local-6989586621679562874"><span class="hs-identifier hs-var">get_or_set</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
forall {b}. Ptr b
</span><a href="#local-6989586621679562872"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-95"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Ptr a
forall {b}. Ptr b
</span><a href="#local-6989586621679562872"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Ptr a -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679562871"><span class="hs-identifier hs-var">ref2</span></a></span><span>
</span><span id="line-96"></span><span>      </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">a -&gt; IO a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679562875"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-97"></span><span>      </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">StablePtr a -&gt; IO ()
forall a. StablePtr a -&gt; IO ()
</span><a href="GHC.Stable.html#freeStablePtr"><span class="hs-identifier hs-var">freeStablePtr</span></a></span><span> </span><span class="annot"><span class="annottext">StablePtr a
</span><a href="#local-6989586621679562873"><span class="hs-identifier hs-var">stable_ref</span></a></span><span>
</span><span id="line-98"></span><span>              </span><span class="annot"><span class="annottext">StablePtr a -&gt; IO a
forall a. StablePtr a -&gt; IO a
</span><a href="GHC.Stable.html#deRefStablePtr"><span class="hs-identifier hs-var">deRefStablePtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr () -&gt; StablePtr a
forall a. Ptr () -&gt; StablePtr a
</span><a href="GHC.Stable.html#castPtrToStablePtr"><span class="hs-identifier hs-var">castPtrToStablePtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr a -&gt; Ptr ()
forall a b. Ptr a -&gt; Ptr b
</span><a href="GHC.Ptr.html#castPtr"><span class="hs-identifier hs-var">castPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679562871"><span class="hs-identifier hs-var">ref2</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-99"></span><span>
</span><span id="line-100"></span></pre></body></html>